fix(transient-render-engine): preserve nested inline boundary spaces#34
fix(transient-render-engine): preserve nested inline boundary spaces#34leineveber wants to merge 1 commit intonative-html:mainfrom
Conversation
Keep boundary spaces inside named inline wrappers until the parent phrasing node collapses sibling whitespace. Add a regression test for nested inline tags that previously rendered "foobar" instead of "foo bar". Made-with: Cursor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #34 +/- ##
=======================================
Coverage 98.65% 98.65%
=======================================
Files 140 140
Lines 2083 2084 +1
Branches 633 634 +1
=======================================
+ Hits 2055 2056 +1
Misses 27 27
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @leineveber, thanks for the contribution! |
| it('should preserve boundary spaces wrapped in nested inline phrasing tags', () => { | ||
| const ttree = makeTTree( | ||
| '<span><span><strong>foo</strong> </span><span><strong>bar</strong></span></span>' | ||
| ); | ||
| const [firstSpan, secondSpan] = ttree.children; | ||
| expect(firstSpan.tagName).toBe('span'); | ||
| expect(firstSpan.children).toHaveLength(2); | ||
| expect((firstSpan.children[0] as TTextImpl).data).toBe('foo'); | ||
| expect((firstSpan.children[1] as TTextImpl).data).toBe(' '); | ||
| expect(secondSpan.tagName).toBe('span'); | ||
| expect(secondSpan.children).toHaveLength(1); | ||
| expect((secondSpan.children[0] as TTextImpl).data).toBe('bar'); | ||
| }); |
There was a problem hiding this comment.
We could use a snaphot, like every other test in this file.
There was a problem hiding this comment.
Also add a test that proves that two spaces are still collapsed into one. In other words
the following:
<span><span><strong>foo</strong> </span><span><strong>bar</strong></span></span>renders the same as your example:
<span><span><strong>foo</strong> </span><span><strong>bar</strong></span></span>
Summary
Fix whitespace collapsing for nested inline phrasing nodes so boundary spaces inside named inline wrappers like span are preserved until the parent phrasing node collapses sibling whitespace correctly.
Adds a regression test for nested inline tags that previously rendered foo bar as foobar.
Closes #33